{!! Form::open(['url'=>URL::to('admin/settings/sitename')]) !!}
    {!! Form::hidden('_method', 'PUT') !!}

    @if (count($locales) > 1)
    <div role="tabpanel" class="locales-panel">

        <!-- Nav tabs -->
        <ul class="nav nav-tabs" role="tablist">
            @foreach($locales as $locale)

            <li role="presentation" class="{{ Session::get('locale') == $locale ? 'active' : null }}">
                <a href="#{{ $locale }}" aria-controls="{{ $locale }}" role="tab" data-toggle="tab">
                    {{ strtoupper($locale) }}
                </a>
            </li>
            @endforeach
        </ul>

        <!-- Tab panes -->
        <div class="tab-content">
            <br />
            @foreach($locales as $locale)
            <div role="tabpanel" class="tab-pane {{ Session::get('locale') == $locale ? 'active' : null }}" id="{{ $locale }}">
                {!! Form::textField("sitename_".$locale, (isset($settings['sitename_' . $locale]) ? $settings['sitename_' . $locale]: null), trans('settings.sitename'), $errors) !!}
            </div>
            @endforeach
        </div>

    </div>
    
    @else
    {!! Form::textField("sitename_".$settings['fallback_locale'], (isset($settings['sitename_' . $settings['fallback_locale']]) ? $settings['sitename_' . $settings['fallback_locale']] : null), trans('settings.sitename'), $errors) !!}
    @endif
    <div class="panel-footer">
        {!! Form::submitButton(trans('temp.save'), 'icon-save', 'class="btn btn-primary"') !!}
    </div>
{!! Form::close() !!}

@section('javascripts')
@parent
<script>
    $(document).ready(function () {
        var locale_tab = "{{ Session::get('locale') or 'en' }}";
        if (locale_tab) {
            $('.locales-panel a[href="#' + locale_tab + '"]').parent().addClass('active');
            $('.locales-panel div#' + locale_tab).addClass('active');
        }
    });
</script>
@stop